home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / MATH / NRPAS13 / GAMMLN.DEM < prev    next >
Text File  |  1991-04-29  |  783b  |  33 lines

  1. PROGRAM d6r1(input,output,dfile);
  2. (* driver for routine GAMMLN *)
  3. CONST
  4.    pi = 3.1415926;
  5. VAR
  6.    i,nval : integer;
  7.    actual,calc,x : real;
  8.    txt : string[14];
  9.    dfile : text;
  10.  
  11. (*$I MODFILE.PAS *)
  12. (*$I GAMMLN.PAS *)
  13.  
  14. BEGIN
  15.    glopen(dfile,'fncval.dat');
  16.    REPEAT readln(dfile,txt) UNTIL (txt = 'Gamma Function');
  17.    readln(dfile,nval);
  18.    writeln ('log of gamma function:');
  19.    writeln ('x':10,'actual':21,'gammln(x)':22);
  20.    FOR i := 1 to nval DO BEGIN
  21.       readln(dfile,x,actual);
  22.       IF (x > 0.0) THEN BEGIN
  23.          IF (x >= 1.0) THEN BEGIN
  24.             calc := gammln(x)
  25.          END ELSE BEGIN
  26.             calc := gammln(x+1.0)-ln(x)
  27.          END;
  28.          writeln (x:12:2,ln(actual):20:6,calc:20:6)
  29.       END
  30.    END;
  31.    close(dfile)
  32. END.
  33.